<template>
	<div class="app-container">
		<div class="content">
			<nextnav :navnum='navnum'></nextnav>
			<el-row :gutter="20">
				<el-col :span="12" :offset="6">
					<div class="grid-content bg-purple success-wrp">
						<el-row :gutter="10">
							<div class="imgwp"><img src="../../assets/images/success.png" width='120px' class='image' /></div>
							<div class="grid-content bg-purple-light success-wrp">
								<div class='suc'>上游政策批次创建成功！</div>
								<div class="policy-basic-wrp">
									<p v-text="info.batchName"></p>
									<p v-if="info.expiryDate!=null">{{info.effectiveDate}}到{{info.expiryDate}}</p>
									<p v-if="info.expiryDate==null">{{info.effectiveDate}}到 无限</p>
								</div>
							</div>
						</el-row>
					</div>
				</el-col>
			</el-row>
			
			<el-row class="button-wrp">
				<el-button class="until-upper-btn" @click="toEdit(0)">继续创建上游政策批次</el-button>
				<!--<el-button type="warning" class="roval-btn" @click="dialogTableVisible = true">提交审核</el-button>-->
				<el-button type="warning" id="roval-btn" class="roval-btn" :disabled="rovalDisa" @click="toRoval()" v-text="rovalHtml"></el-button>
			</el-row>


			<el-dialog title="审核提示" :visible.sync="dialogTableVisible" width="500px" class="toDis-dialog upper4-dialog" :close-on-click-modal="false">
				<p class="dialog-tit">该政策所选工号与以下政策批次中的工号冲突，是否确认提交审核！</p>
				<div class="dialog-max">
					<div class="visi-wrp" v-for="(item,index) in list">
						<!--<div class="visi-wrp">-->
						<div class="visi-list">
							<div>{{inem.index+1}}&nbsp;&nbsp;{{item.batchName}}</div>
							<div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;有效时间：{{item.effectiveDate}}到{{item.expiryDate}}</div>
						</div>
					</div>
				</div>
				<div slot="footer" class="dialog-footer">
					<el-button class="upper4-sureBtn" @click="toEdit(batchId)">去修改</el-button>
					<el-button class="upper4-sureBtn" type="primary" @click="toRoval_sure()">确 定</el-button>
				</div>
			</el-dialog>

		</div>
	</div>

</template>

<script>
	import nextnav from './assembly/nextnav'
	export default {
		data() {
			return {
				navnum: 3,
				value: "",
				//chosedates: "支付日期",
				islimit: true,
				options: [],
				workoptions: [],
				endateprop: "",
				//batchId:'63630919-5ddb-4aba-ae25-0ef95e3d63f6',
				batchId: null,
				info: {},
				list: null,
				oldPolicyBatchId: '',
				dialogTableVisible: false,
				rovalDisa:false,
				rovalHtml:'提交审核'

			}
		},
		mounted() {
			this.batchId = this.$route.query.batchId;
			//this.batchId = '17c65540-7b68-404f-a03d-6135e289c20c';
			this.getinter();
		},
		methods: {
			//获取信息
			getinter() {
				let params = {
					id: this.batchId
				};
				this.post(params, "services/app/policy/GetPolicyBatchBasic").then(res => {
					this.info = res.result;
					console.log('s')
					console.log(this.info)
				});

				this.post(params, "services/app/policy/CheckEffectivedPolicyBatch").then(res => {
					this.list = res.result.items;
					console.log('su2')
					console.log(this.list)
					//					var oldId = '';
					//					this.list.forEach(item => {
					//		              oldId += item.policyBatchId + ',';					  
					//		            });
					//var  OldID = (oldId .substring(oldId .length - 1) == ',') ? oldId .substring(0, oldId .length - 1) : oldId ;
					//		            this.oldPolicyBatchId = OldID;
					//		            console.log(this.oldPolicyBatchId)
				});
			},
			//去修改
			toEdit(batchId) {
				this.$router.push({
					name: 'policyupper1',
					params: {
						id: batchId
					}
				});
			},
			//提交审核post
			toRovalPost() {
				let params = {
					policyBatchId: this.batchId
				}
				this.post(params, 'services/app/policy/UpdatePolicyBatchStateToApprovalPending').then(re => {
					if(re.success) {
						this.rovalHtml='已提交';
						this.rovalDisa=true;
						this.successNot();
					}else{
						this.failNot(re.error.message)
					}
				});
			},
			//提交审核（一级
			toRoval() {
				//const me = this;
				//如果无冲突批次
				if(this.oldPolicyBatchId == '') {
					var txt = '确定提交审核吗？'
					this.$confirm(txt, '审核提示', {
						confirmButtonText: '确定',
						cancelButtonText: '取消',
						closeOnClickModal:false
						// type: 'warning'
					}).then(() => {
						this.toRovalPost();

					});

					return false;
				}

				//如果有冲突批次
				this.dialogTableVisible = true;

			},
			//提交审核（二级
			toRoval_sure() {
				this.dialogTableVisible = false;
				this.toRovalPost();
			},
			//保存成功提示
		    successNot(){
		    	const h = this.$createElement;
		      	this.$notify({
		          title: '提交成功',
		          message: '您已成功提交一条上游批次',
		          type: 'success',
		          customClass:"el-notification-success"
		        });
		    },
		    //保存失败提示
		    failNot(message){
		    	const h = this.$createElement;
		      	this.$notify.error({
		          title: '保存失败',
		          message: message,
		          duration: 0,
		          customClass:"el-notification-error"
		        });
		    }
		},
		components: {
			nextnav,
		}

	}
</script>
<style lang="scss" scoped>
.app-container{height: 811px;}
	.content {
		width: 1005px;
		height: 100%;
		margin: 0 auto;
	}	
	.el-row {
		margin-bottom: 20px;
		&:last-child {
			margin-bottom: 0;
		}
	}	
	.button-wrp {
		text-align: center;
	}	
	.until-upper-btn,
	.roval-btn {
		width: 190px;
		padding: 0;
		text-align: center;
		height: 32px;
		border-radius: 5px;
		font-family: PingFangSC-Regular;
		font-size: 14px;
		margin-left: 30px;
		margin-right: 30px;
		display: inline-block;
	}	
	.until-upper-btn {
		background: #F7F7F7;
		border: 1px solid #DDDDDD;
		color: #666666;
	}	
	.until-upper-btn:hover {
		background: #F7F7F7;
		border: 1px solid #666666;
		color: #666666;
	}
	
	.roval-btn {
		background: #FF7819;
		border: 1px solid #EE6000;
		color: #FFFFFF;
	}
	
	.suc {
		font-family: PingFangSC-Medium;
font-size: 24px;
color: #333333;
letter-spacing: 0;margin-bottom: 30px;
	}
	
	.el-col {
		border-radius: 4px;
	}
	
	.bg-purple-dark {
		background: #99a9bf;
	}
	
	.bg-purple {
		background: #d3dce6;
	}
	
	.bg-purple-light {
		background: #e5e9f2;
	}
	
	.grid-content {
		border-radius: 4px;
		min-height: 36px;
	}
	
	.row-bg {
		padding: 10px 0;
		background-color: #f9fafc;
	}
	
	.success-wrp {
		background: transparent;
	}
	
	.dialog-max {
		width: 100%;
		height: 200px;
		overflow-y: auto;
	}
	.visi-wrp{padding: 6px 0;box-sizing: border-box;width: 80%;margin: 0 auto;font-size: 12px;height: 200px;overflow-y: auto;}
	.imgwp{margin-top: 50px;margin-bottom: 50px;}
	.image{display: block;margin: 0 auto;}
	.success-wrp{text-align: center;}
	.success-wrp>div{text-align: center;}
	.policy-basic-wrp p{font-family: PingFangSC-Regular;
font-size: 13px;
color: #333333;margin-bottom: 10px;}
.button-wrp{margin-top: 40px;}
</style>
<!--<style type="text/css">
	.impact-title{text-align: center;}
	.impact-list-wrp{padding:5px 60px;box-sizing: border-box;}
	
	#list-list{display: none;}
	.el-dialog__body{max-height: 300px;overflow-y: auto;}
	.gray-btn{background: #DDDDDD;}
	.dialog-tit{text-align: center;font-size: 12px;}
	.upper4-dialog .el-dialog__header{border-bottom: 1px solid #BCBCBC;}
	.upper4-dialog .el-dialog_body{overflow-y: auto;}
	.visi-wrp{padding: 6px 0;box-sizing: border-box;width: 80%;margin: 0 auto;font-size: 12px;height: 200px;overflow-y: auto;}
	.upper4-dialog .el-dialog__footer{text-align: center;}
	.upper4-sureBtn{width: 140px;height: 30px;line-height: 30px;display: inline-block;padding: 0;margin-left: 23px;margin-right: 23px;}
	.visi-list{margin-bottom: 10px;}
</style>-->